<?php
/**
 * Created by PhpStorm.
 * User: ytl003
 * Date: 2018/9/26
 * Time: 下午9:37
 */

namespace app\api\controller;

use app\api\service\Back;
use app\api\service\TokenService;
use app\api\service\UserService;
use app\api\service\WxService;
use think\facade\Cache;
use think\facade\Request;

class Token
{
    /**
     * @route('token/user')
     * @param string $type
     * @return array
     * @throws \app\lib\exception\TokenException
     */
    public function tokenUser($type=''){
        $user = new UserService();
        return Back::success($user->grantToken($type));
    }

    /**
     * @return array
     * @route('token/verify')
     */
    public function tokenVerify(){
        return Back::success(TokenService::verifyToken());
    }

    /**
     * @route('token/remove')
     */
    public function remote(){
        $token = Request::header('token');
        if (!$token)
            $token = Request::cookie('token');
        if (Cache::pull($token))
            return Back::success();
    }

}